from time import sleep

from selenium.webdriver.common.by import By

from testing.testHomework2.poHomeWork.Page.basePage import BasePage



class AddDepartmentPage(BasePage):
    # 输入部门元素
    _addDepartments = (By.XPATH, '//*[@id="__dialog__MNDialog__"]/div/div[2]/div/form/div[1]/input')
    # 选择部门
    _selectDepartments = (By.CSS_SELECTOR, '.js_toggle_party_list')
    _selectDepartment = (By.XPATH, '//*[@id="__dialog__MNDialog__"]/div/div[2]/div/form/div[3]/div')
    # 点击确定
    _action = (By.XPATH, '// *[ @ id = "__dialog__MNDialog__"] / div / div[3] / a[1]')
    def addDepartment(self):
        from testing.testHomework2.poHomeWork.Page.contactPage import ContactPage
        self.find(*self._addDepartments).send_keys('测试1')
        self.find_and_click(*self._selectDepartments)
        sleep(2)
        self.find_and_click(*self._selectDepartment)
        self.find_and_click(*self._action)
        return ContactPage(self.driver)